<template>
	<div>
		<HomeHeader></HomeHeader>
		<HomeLeft :cur="2"></HomeLeft>
		<div id="main">
			<div id="web_con">
				<div class="web_wp">
					<div class="web_location">
						<div class="here_area">
							<strong>当前位置：</strong>会员管理
						</div>
						<div class="here_btn">

						</div>
					</div>
					<div class="filter clearfix">
						<div class="aa">


							<div class="item">
								<span>开始时间：</span>
								<el-date-picker v-model="start_time" type="date" placeholder="开始时间"
									value-format="yyyy-MM-dd">
								</el-date-picker>
							</div>

							<div class="item">
								<span>结束时间：</span>
								<el-date-picker v-model="end_time" type="date" placeholder="结束时间"
									value-format="yyyy-MM-dd">
								</el-date-picker>
							</div>

							<div class="item">
								<span>关键词：</span>
								<input type="text" v-model="keywords" placeholder="请输入" class="fill_text">
							</div>

							<div class="item">
								<button class="but_search" @click="Seach()">搜 索</button>
							</div>
						</div>
						<div class="bb">

							<a href="javascript:;" class="web_btn btn_refresh" @click="ExportList()"><em
									class="iconfont icon-shdcexcel"></em>导出</a>

							<!-- <navigator url="/pages/member/add" hover-class="none" class="web_btn">

								<em class="iconfont icon-shdcsub-add"></em>添加
							</navigator> -->
							<!-- <a href="javascript:;" class="web_btn" @click="DeleteList()">
								<em class="iconfont icon-shdcsub-add-copy"></em>删除
							</a> -->

							<!-- <a href="javascript:;" class="web_btn" @click="DeleteList()">
								<em class="iconfont icon-shdcsub-add-copy"></em>冻结
							</a> -->
							<a href="javascript:;" class="web_btn btn_refresh" @click="Refresh()"><em
									class="iconfont icon-shdcshuaxin"></em>刷新</a>
						</div>
					</div>

					<div class="web_table">
						<table>
							<tr>
								<!-- <th class="tac" style="width: 60px;">选择</th> -->
								<th class="tac">股东卡编号</th>
								<th class="tac">姓名</th>
								<th class="tac">手机号</th>
								<!-- <th class="tac">性别</th> -->
								<th class="tac">身份证号</th>
								<th class="tac">注册时间</th>
								<th class="tac">商户号</th>
								<th class="tac">所属商户</th>
								<th class="tac">余额</th>
								<th class="tac">预计收益</th>
								<th class="tac">积分</th>
								<!-- <th class="tac">注册时间</th> -->
								<th class="tac">编辑</th>
							</tr>
							<tr v-for="(item,i) in listinfo.data" :key="i">
								<!-- <td class="tac">
									<el-checkbox v-model="item.checked"></el-checkbox>
								</td> -->
								<td class="tac">{{item.uno}}</td>
								<td class="tac">{{item.nickname}}</td>
								<td class="tac">{{item.phone}}</td>
								<!-- <td class="tac">{{item.gender}}</td> -->
								<td class="tac">{{item.idcard}}</td>
								<td class="tac">{{common.DateToString(item.created_at,1)}}</td>
								<td class="tac">{{item.merchantno}}</td>
								<td class="tac">
									<span v-if="item.company">{{item.company.name}}</span>
								</td>
								<td class="tac">
									<navigator class="txt_link"
										:url="'/pages/member/money?id=' + item.id + '&zong=' + item.balance"
										hover-class="none">{{item.balance}}
									</navigator>
								</td>
								<td class="tac">
									<navigator class="txt_link"
										:url="'/pages/member/expect?id=' + item.id + '&name=' + item.nickname + '&money=' + item.predict"
										hover-class="none">{{item.predict}}
									</navigator>
								</td>
								<td class="tac">
									<navigator class="txt_link"
										:url="'/pages/member/integral?id=' + item.id + '&zong=' + item.integral"
										hover-class="none">{{item.integral}}
									</navigator>
								</td>
								<td class="tac">
									<navigator :url="'/pages/member/edit?id=' + item.id" hover-class="none"
										class="editBtn" title="编辑">
									</navigator>
								</td>
							</tr>
						</table>
					</div>
					<div class="web_page">
						<el-pagination background @current-change="ChengPage" :current-page="page" :page-size="10"
							layout="total,prev, pager,next" :total="listinfo.total">
						</el-pagination>
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import HomeHeader from '../components/Header.vue'
	import HomeLeft from '../components/Left.vue'
	export default {
		components: {
			HomeHeader,
			HomeLeft,

		},
		data() {
			return {
				page: 1,
				listinfo: [],
				keywords: '',
				start_time: '',
				end_time: '',
			}
		},
		onLoad(e) {

		},
		onShow(options) {
			let that = this;
			let params = this.$route.query;
			if (params.time == 0) {
				that.start_time = that.common.GetNowTime();
				that.end_time = that.common.GetNowTime();
			} else if (params.time == 1) {
				var _tiem = that.common.GetNowTime();
				that.start_time = _tiem.slice(0, 8) + "01";
				that.end_time = that.common.GetNowTime();
			}
			this.GetList();
		},
		methods: {
			//导出
			ExportList:function(){
				let that = this;
				let _data = {
					keywords: that.keywords,
					range:[],
					export:'user'
				};
				if(that.start_time){
					_data.range[0] = that.start_time;
					_data.range[1] = that.end_time?that.end_time:that.start_time
				}
				else if(that.end_time){
					_data.range[0] = that.start_time?that.start_time:that.end_time
					_data.range[1] = that.end_time
				}
				console.log(_data);
				var _url = 'http://bylm.zxinvest.cn/api/admin/user?export=user&keywords=' + that.keywords + '&range=' +_data.range + '&token=' + that.common.GetStorage('bytoken');	
				
				
				// 创建一个隐藏的<iframe>元素
				const iframe = document.createElement('iframe');
				iframe.style.display = 'none';				
				// 设置<iframe>的src为接口地址
				iframe.src = _url;				
				// 将<iframe>添加到文档中
				document.body.appendChild(iframe);
							
							
				// window.open(_url, '_blank');
			},
			

			Refresh: function() {
				this.keywords = '';
				this.start_time = '';
				this.end_time = '';
				this.Seach();
			},

			Seach: function() {
				this.page = 1;
				this.GetList();
			},


			ChengPage: function(e) {
				this.page = e;
				this.GetList();
			},


			GetList: function() {
				let that = this;
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				let _data = {
					keywords: that.keywords,
					page: that.page,
					per_page: 10,
					range:[],
				};
				if(that.start_time){
					_data.range[0] = that.start_time;
					_data.range[1] = that.end_time?that.end_time:that.start_time
				}
				else if(that.end_time){
					_data.range[0] = that.start_time?that.start_time:that.end_time
					_data.range[1] = that.end_time
				}
				console.log(_data);
				that.common.http('GET', 'user', _data, function(res) {
					uni.hideLoading();
					console.log(res.data.data)
					that.listinfo = res.data
				});
			},
			LookTest: function(id) {
				uni.navigateTo({
					url: '/pages/member/info?id=' + id
				})
			},
		}
	}
</script>

<style>


</style>